package seata.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import seata.feign.SeataTableThreeClient;
import seata.feign.SeataTableTwoClient;
import seata.service.SeataTableOneService;

@RestController
public class Provider8801Controller {
    @Autowired
    private SeataTableOneService seataTableOneService;
    @Autowired
    private SeataTableTwoClient seataTableTwoClient;
    @Autowired
    private SeataTableThreeClient seataTableThreeClient;

    @GetMapping("/c1")
    public String c1(){
        return seataTableOneService.getById(1).toString();
    }

    @GetMapping("/c2")
    public String c2(){
        return seataTableTwoClient.c1();
    }

    @GetMapping("/update2")
    public String update2(){
        seataTableTwoClient.update("2");
        return "success";
    }

    @GetMapping("/update3")
    public String update3(){
        seataTableThreeClient.update("3");
        return "success";
    }

    @GetMapping("/update/{name1}/{name2}/{name3}")
    public String update(@PathVariable String name1, @PathVariable String name2, @PathVariable String name3){
        seataTableOneService.updateSeataTableOneToThree(name1, name2, name3);
        return "success";
    }
}
